package itheima.com.myReflect;

import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Properties;

public class Demo {
    public static void main(String[] args) throws ClassNotFoundException, IOException, NoSuchMethodException, IllegalAccessException, InstantiationException, InvocationTargetException {
        ClassLoader systemClassLoader = ClassLoader.getSystemClassLoader();
        InputStream is = systemClassLoader.getResourceAsStream("pro.properties");
        Properties properties = new Properties();
        properties.load(is);
        is.close();

     /*   Class clazz = Class.forName(properties.getProperty("classname"));
        Object o = clazz.newInstance();
        Method method = clazz.getMethod(properties.getProperty("methodname"),String.class,int.class);
        Object invoke = method.invoke(o,"zhangsan",25);
        System.out.println(invoke);*/

        Class clazz = Class.forName(properties.getProperty("classname"));
        Object o = clazz.newInstance();
        Method method = clazz.getMethod("work");
        method.invoke(o);
    }
}
